package com.example.demonstrate.wang.test;

/**
 * @Author along
 * @Date 2024/6/20 0:36
 * @Description 双重检测锁实现对象单例
 */
public class Singleton {
    private volatile static Singleton uniqueInstance;

    private Singleton() {
    }

    private static Singleton getUniqueInstance() {
        if(uniqueInstance == null) {
            synchronized (Singleton.class) {
                if(uniqueInstance == null) {
                    uniqueInstance = new Singleton();
                }
            }
        }
        return uniqueInstance;
    }
}
